package ar.com.solidussource.howmuchservices.common.entities.filter;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import ar.com.solidussource.framework.backend.dao.filter.OrderedFilter;

public class AddressFilter extends OrderedFilter {
	
	public Integer getLocationId() {
		return locationId;
	}

	public void setLocationId(Integer locationId) {
		this.locationId = locationId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	private Integer locationId;
	private String name;

	@Override
	public void fillCriteriaNotPagination(Criteria arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void fillCriteriaNoOrder(Criteria criteria) {
		if (getLocationId() != null) {
			criteria.add(Restrictions.eq("location.id", this.locationId));
		}
		if (getName() != null) {
			criteria.add(Restrictions.like("name", this.name+"%"));
		}	
		
	}

}
